﻿#ifndef DEPTVO_H
#define DEPTVO_H

#include <QObject>
#include "qbaseentity.h"
#include <dept.h>

class DeptVO : public QBaseEntity
{
    Q_OBJECT
    // 使用 Q_PROPERTY 宏定义属性
    Q_PROPERTY(QList<DeptVO> children READ getChildren WRITE setChildren)
    Q_PROPERTY(uint64_t id READ getId WRITE setId)
    Q_PROPERTY(QString name READ getName WRITE setName)
    Q_PROPERTY(uint64_t pid READ getPid WRITE setPid)
    Q_PROPERTY(QString remark READ getRemark WRITE setRemark)
    Q_PROPERTY(int status READ getStatus WRITE setStatus)
public:
    DeptVO(QObject *parent = nullptr);
    ~DeptVO();

    QJsonObject toJsonObject(PropertiesType type = AllProperty,QStringList propertyList = QStringList()) const override;
    void fromJsonObject(const QJsonObject &jsonObject) override;

    void fromDept(const Dept &dept);
    void toDept(Dept &dept);


    QList<DeptVO> getChildren() const;
    void setChildren(const QList<DeptVO> &value);

    uint64_t getId() const;
    void setId(const uint64_t &value);

    QString getName() const;
    void setName(const QString &value);

    uint64_t getPid() const;
    void setPid(const uint64_t &value);

    QString getRemark() const;
    void setRemark(const QString &value);

    int getStatus() const;
    void setStatus(int value);

private:
    QList<DeptVO> children; /**< 子集 */
    uint64_t id; /**< ID */
    QString name; /**< 名称*/
    uint64_t pid; /**< 父级ID */
    QString remark;/**< 备注 */
    int status;/**< 状态*/

};
Q_DECLARE_METATYPE(QList<DeptVO>) //注册到元数据对象
#endif // DEPTVO_H
